<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="/ui/jsp/includes/header.jspf"%>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<%-- <script src="<%=request.getContextPath()%>/ui/js/paginate.js"></script> --%>
<%-- <script src="<%=request.getContextPath()%>/ui/js/customPaginate.js"></script> --%>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>

<script type="text/javascript">
	function viewCategory(categoryId) {
		$('#categoryId').val(categoryId);
		$('#viewCategoryForm').attr('action', 'viewExistingCategory.html');
		$('#viewCategoryForm').submit();
	}
	function addNewCategory() {
		$('#viewCategoryForm').attr('action', 'viewNewCategory.html');
		$('#viewCategoryForm').submit();
	}
</script>

<div class="hero-unit secondary_container">
	<div id="table-subject-header">
		View Category List
		<hr>
	</div>
	<div class="row-fluid">
		<form method="POST" id="viewCategoryForm">

			<div class="addnew_button">
				<input type="button" value="Add New Category" onclick="javascript:addNewCategory()" class="btn btn-primary">
			</div>
			<div class="span10">
				<table id='dataTableList' class="table table-striped table-bordered">
					<thead>
						<tr>
							<c:if test="${roleId==1 || roleId==3}">
								<th width="8%">Action</th>
							</c:if>
							<th>Category Name</th>
							<th>Description</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="category" items="${categoryList}">
							<tr class="paginationList">
								<c:if test="${roleId==1 || roleId==3}">
									<td><a href="javascript:viewCategory('${category.categoryId}')"><img	src="<%=request.getContextPath()%>/ui/images/edit.gif" title="Edit"/></a></td>
								</c:if>
								<td>${category.categoryName}</td>
								<td>${category.description}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				
				<div class="pagination">
                </div>
				
				
			</div>
			<input type="hidden" id="categoryId" name="categoryId" value=""/>
		</form>
	</div>
</div>
<%@include file="/ui/jsp/includes/footer.jspf"%>


